local kongtan = fk.CreateSkill{
  name = "hanqing__kongtan",
}

Fk:loadTranslationTable{
  ["hanqing__kongtan"] = "空谈",
  [":hanqing__kongtan"] = "准备阶段或结束阶段，你可以视为使用一张基本牌。然后若有角色体力值因此变化，你弃置一张牌；若本回合有与此牌同名的牌"..
  "被使用过，你失去1点体力。",

  ["#hanqing__kongtan-invoke"] = "空谈：你可以视为使用一张基本牌",

  ["$hanqing__kongtan1"] = "白起遇臣，如秋叶遇风，当迅扫也。",
  ["$hanqing__kongtan2"] = "来日大战，定要生擒王龁，与诸侯做个笑话。",
}

kongtan:addEffect(fk.EventPhaseStart, {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(kongtan.name) and
      (player.phase == Player.Start or player.phase == Player.Finish) and
      #player:getViewAsCardNames(kongtan.name, Fk:getAllCardNames("b"), nil, nil, { bypass_times = true }) > 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local use = room:askToUseRealCard(player, {
      pattern = room:getBanner(kongtan.name),
      skill_name = kongtan.name,
      prompt = "#hanqing__kongtan-invoke",
      cancelable = true,
      extra_data = {
        bypass_times = true,
        extraUse = true,
        expand_pile = room:getBanner(kongtan.name),
      },
      skip = true,
    })
    if use then
      event:setCostData(self, {extra_data = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local use = event:getCostData(self).extra_data
    local card = Fk:cloneCard(use.card.name)
    card.skillName = kongtan.name
    use.card = card
    local hp_recorder = table.map(room.players, function (p)
      return p.hp
    end)
    local use_recorder = #player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
      local u = e.data
      return u.card.trueName == use.card.trueName
    end, Player.HistoryTurn)
    room:useCard(use)
    if player.dead then return end
    if not player:isNude() then
      local yes = false
      for i = 1, #room.players, 1 do
        if room.players[i].hp ~= hp_recorder[i] then
          yes = true
          break
        end
      end
      if yes then
        room:askToDiscard(player, {
          min_num = 1,
          max_num = 1,
          include_equip = true,
          skill_name = kongtan.name,
          cancelable = false,
        })
      end
    end
    if player.dead then return end
    if use_recorder > 0 then
      room:loseHp(player, 1, kongtan.name)
    end
  end,
})

kongtan:addAcquireEffect(function (self, player, is_start)
  local room = player.room
  if not room:getBanner(kongtan.name) then
    local cards = {}
    for _, name in ipairs(Fk:getAllCardNames("b")) do
      table.insert(cards, room:printCard(name).id)
    end
    room:setBanner(kongtan.name, cards)
  end
end)

return kongtan
